<?php
/**
 * @file			authImage.mod.php
 * @CopyRight		(C)1996-2099 SINA Inc.
 * @Project			Waitan
 * @Author			pengyong <pengyong@staff.sina.com.cn>
 * @Create Date:	2011-09-07
 * @Modified By:	pengyong/2011-09-08
 * @Brief			随机验证码
 */
class index_ctrl extends controls_base{
	function default_action(){
		//$this->paint();
		$id=(int)V('g:id',2);
		$date=V('g:date',NULL);
		$date_min=mktime(0,0,0,1,1,2000);
		$date_max=time()+24*60*60;
		if(strlen($date)==8){
			$date_unix=mktime(0,0,0,substr($date,4,2),substr($date,6,2),substr($date,0,4));
			
			if($date_unix<$date_min){
				
				$date=NULL;
			}
			elseif($date_unix>$date_max){
				$date=NULL;
			}
			if(($date_max-$date_unix)<24*60*60){
				TPL::assign('date_tomorrow_link',FALSE);
			}
			elseif(($date_unix-$date_min)<24*60*60){
				TPL::assign('date_yesterday_link',FALSE);
			}
		}
		else{
			$date=NULL;
		}
		//if(!$date){
		//	APP::redirect('index',2);
		//}
		if(!$date){
			$date=date('Ymd',time());
		}
		
		$date_yesterday=date('Ymd',mktime(0,0,0,substr($date,4,2),substr($date,6,2),substr($date,0,4))-24*60*60);
		$date_tomorrow=date('Ymd',mktime(0,0,0,substr($date,4,2),substr($date,6,2),substr($date,0,4))+24*60*60);
		TPL::assign('date_now',$date);
		TPL::assign('date_yesterday',$date_yesterday);
		TPL::assign('date_tomorrow',$date_tomorrow);
		TPL::assign('date_today',date('Ymd',time()));
		
		$rst=F::api('constell/tread/get',array('id'=>$id,'date'=>$date));
		if(isset($rst['rst'])&&$rst['rst']){
			TPL::assign('list',$rst['rst']);
		}
		//var_dump($rst);
		//exit();
        TPL::display('index');
	}
	
	function article(){
		$rst=F::api('article');
		var_dump($rst);
	}
	
}